<%@ page  contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="h" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ page import="limousine.util.*" %>
<script language="JavaScript" type="text/JavaScript" src="app/js/wz_tooltip.js"></script>

<div class="data_form">
    <div class="head_data_form">
    </div>
    <div class="show_form">
        <table width="100%" cellspacing="10" cellpadding="0">
            <tr>
                <td align="right">
                    <form id="form1" name="form1" method="post" action="">
                        <input type="button" name="button" id="button" value="เพิ่ม User" onclick="javascript:goUrl('usersinsertinit.do');" />
                    </form>
                </td>
            </tr>
        </table>

        <table width="100%" border="0" cellspacing="10" cellpadding="0">
            <tr>
                <td><strong>Users Manager</strong></td>
            </tr>
            <tr>
                <td>
                    <fieldset>
                        <legend>
                            <strong>search condition</strong></legend>
                        <table width="100%" border="0" cellspacing="5" cellpadding="0">
                            <tr>
                                <td align="center">
                                    <table class="tableForm">
                                        <tr><td valign="center">
                                                <jsp:include page="sys_msg.jsp" />
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr><td align="center">
                                    <h:form action="/usersmanagerquery">
                                        <table class="tableForm" border="0">
                                            <tr><td class="textFormLabel" align="right" width="45%">User Name:</td>
                                                <td align="left"><h:text property="userName" styleClass="textBox" size="25"/>
                                                </td>
                                            </tr>                                            
                                            <tr><td class="textFormLabel" align="right" >Name:</td>
                                                <td align="left" ><h:text property="name" styleClass="textBox" size="25"/>
                                                </td>
                                            </tr>
                                            <tr><td class="textFormLabel" align="right">Gender:</td>
                                                <td align="left">
                                                    <h:select property="gender" styleClass="combo" >
                                                        <logic:present name="<%=Token.USERS_GENDER_LIST%>">
                                                            <logic:iterate id="funcs" scope="session" type="limousine.util.SelectItem"
                                                            name="<%=Token.USERS_GENDER_LIST%>">
                                                        <option value="<%=funcs.getKey()%>"  <%=(funcs.getSelect()) ? "selected" : ""%> ><%=funcs.getValue()%></option>
                                                    </logic:iterate>
                                                </logic:present>
                                            </h:select>
                                    </td>
                                </tr>
                                <tr><td class="textFormLabel" align="right" >Email:</td>
                                    <td align="left" ><h:text property="email" styleClass="textBox" size="25"/>
                                    </td>
                                </tr>

                                <tr><td class="textFormLabel" align="right">Member Status:</td>
                                    <td align="left">
                                        <h:select property="enable" styleClass="combo" >
                                            <logic:present name="<%=Token.USERS_ENABLE_LIST%>">
                                                <logic:iterate id="funcs" scope="session" type="limousine.util.SelectItem"
                                                name="<%=Token.USERS_ENABLE_LIST%>">
                                            <option value="<%=funcs.getKey()%>"  <%=(funcs.getSelect()) ? "selected" : ""%> ><%=funcs.getValue()%></option>
                                        </logic:iterate>
                                    </logic:present>
                                </h:select>
                                </td>
                                </tr>
                                <tr><td class="textFormLabel" align="right">Online Status:</td>
                                    <td align="left">
                                        <h:select property="status" styleClass="combo" >
                                            <logic:present name="<%=Token.USERS_STATUS_LIST%>">
                                                <logic:iterate id="funcs" scope="session" type="limousine.util.SelectItem"
                                                name="<%=Token.USERS_STATUS_LIST%>">
                                            <option value="<%=funcs.getKey()%>"  <%=(funcs.getSelect()) ? "selected" : ""%> ><%=funcs.getValue()%></option>
                                        </logic:iterate>
                                    </logic:present>
                                </h:select>
                                </td>
                                </tr>
                                <tr><td class="textFormLabel" align="right">Role:</td>
                                    <td align="left">
                                        <h:select property="roleId" styleClass="combo" >
                                            <logic:present name="<%=Token.USERS_ROLE_LIST%>">
                                                <logic:iterate id="funcs" scope="session" type="limousine.util.SelectItem"
                                                name="<%=Token.USERS_ROLE_LIST%>">
                                            <option value="<%=funcs.getKey()%>"  <%=(funcs.getSelect()) ? "selected" : ""%> ><%=funcs.getValue()%></option>
                                        </logic:iterate>
                                    </logic:present>
                                </h:select>
                                </td>
                                </tr>
                                <tr height="5"><td class="text" align="center" colspan="2">
                                    </td>
                                </tr>
                                <tr><td class="text" align="center" colspan="2">
                                        <input type="submit" value="Search" />&nbsp;
                                        <input type="reset" value="Clear" />
                                    </td>
                                </tr>
                            </table>
                        </h:form>
                </td>
            </tr>
        </table>
        </fieldset>
        </td>
        </tr>
        </table>

        

        <!-- record -->
        <logic:present name="<%=Token.USERS%>">
            <table width="100%" border="0" cellspacing="0" cellpadding="10">
                <tr>
                    <td>
                        <fieldset class="bold-th">
                            <legend><strong>search result</strong></legend>
                            <table width="100%" cellspacing="1" cellpadding="1" border="0">
                                <tbody><tr valign="top" align="center">
                                        <th bgcolor="#9a9a9a">No.</th>
                                        <th bgcolor="#9a9a9a">UserName</th>
                                        <th bgcolor="#9a9a9a">Name</th>
                                        <th bgcolor="#9a9a9a">Gender</th>
                                        <th bgcolor="#9a9a9a">CreateDate</th>
                                        <th bgcolor="#9a9a9a">LastLogin</th>
                                        <th bgcolor="#9a9a9a">Role</th>
                                        <th bgcolor="#9a9a9a">MemberStatus</th>
                                        <th bgcolor="#9a9a9a">Online</th>
                                        <th bgcolor="#9a9a9a">Edit</th>
                                        <!--th bgcolor="#9a9a9a">Del</th-->
                                    </tr>
                                    <%
                                                Func func = new Func();
                                    %>
                                    <logic:iterate id="bean" indexId="count" scope="session" type="limousine.vo.Users" name="<%=Token.USERS%>">
                                        <tr bgcolor="#f0f0f0" onmouseout="this.bgColor='#F0F0F0'" onmouseover="this.bgColor='#CCCC99'">
                                            <td align="center" width="8%" ><%=count + 1%></td>
                                            <td width="10%" ><bean:write name="bean" property="userName" /></td>
                                            <td width="20%"><a href="#" onmouseover="Tip('<%=bean.getEmail()%>:<%=bean.getPhone()%>');" ><%=bean.getName()%></a></td>
                                            <td align="center" width="3%" ><%=(bean.getGender().equals("m")) ? "<img src='app/images/icon_gender_male.png'/>" : "<img src='app/images/icon_gender_female.png'/>"%></td>
                                            <td align="center" width="20%" ><bean:write name="bean" property="createDate" /></td>
                                            <td align="center" width="20%" ><bean:write name="bean" property="lastLogin" /></td>
                                            <td align="center" width="20%" ><bean:write name="bean" property="roleName" /></td>
                                            <td align="center" width="3%" ><%=(bean.getEnable().equals("1")) ? "<img src='app/images/online.png'/>" : "<img src='app/images/offline.png'/>"%></td>
                                            <td align="center" width="3%" ><%=(bean.getStatus().equals("1")) ? "<img src='app/images/online.png'/>" : "<img src='app/images/offline.png'/>"%></td>
                                            <td align="center" width="3%" ><a  href="userseditinit.do?eid=<%=bean.getId()%>" id="E<%=bean.getId()%>" >
                                                    <img src="app/images/edit.gif" border="0" alt="E<%=bean.getId()%>"/>
                                                </a></td>
                                            <!--td align="center" width="3%" ><a href="#" id="D<%//=bean.getId()%>" onclick="javascript:goDelete('usersmanagerdelete.do?did=<%//=bean.getId()%>','D<%//=bean.getId()%>','Confirm remove [<%//=func.displayTextByLenght(bean.getUserName(), 70)%>]');" >
                                                    <img src="app/images/delete.gif" border="0" alt="D<%//=bean.getId()%>"/>
                                                </a></td-->
                                        </tr>                                        
                                    </logic:iterate>
                                </tbody>
                            </table>
                        </fieldset>
                    </td>
                </tr>
            </table>
        </logic:present>
        <!-- record -->

        <!-- Make page -->
        <logic:present name="<%=Token.USERS_PAGE%>">
            <table class="table" width="95%" align="center">
                <tr><td class="text" align="left" colspan="16">
                        <%String offset = (String) session.getAttribute(Token.USERS_CURRENT_OFFSET);                                    
                        %>
                        <logic:iterate id="pits" indexId="pageCount" scope="session"
                        type="limousine.util.PageIterator" name="<%=Token.USERS_PAGE%>">
                            <%if (offset.equals(pits.getNumber())) {%>
                            [<font color="black"><b><%=pageCount+1%></b></font>]&nbsp;
                            <%} else {%>
                            <a style="color: #FFFFFF" href="javascript:void(0);" id="<%=pits.getNumber()%>" onClick="javascript:goLink('<%=pits.getLink()%>?offset=<%=pits.getNumber()%>','<%=pits.getNumber()%>');">
                                <font color="blue"><b><%=pageCount+1%></b></font></a>&nbsp;
                                <%}%>                                
                            </logic:iterate>
                    </td>
                </tr>
            </table>
        </logic:present>
        <!-- Make page -->

    </div>
    <div class="bottom_data_form">
    </div>
</div>

